public class HelloWorld {
    public static void main(String[] args) {
        String str = "123";
        int num = Integer.parseInt(str);
        System.out.println(num);
    }
    public static void main15(String[] args) {
        int num = 10;
        //方法1
        String str1 = num + "";
        System.out.println(str1);
        //方法2
        String str2 = String.valueOf(num);
        System.out.println(str2);
    }
    public static void main14(String[] args) {
        String s1 = "Hello ";
        String s2 = "world!";
        System.out.println(s1);
        System.out.println(s2);
        //表示把字符串s1和s2进行拼接
        System.out.println(s1+s2);
    }
    public static void main13(String[] args) {
        byte a = 10;
        byte b = 20;
        //代码编译失败
        //byte c = (a+b);
        //代码运行成功
        byte c = (byte) (a+b);
        System.out.println(c);
    }
    public static void main12(String[] args) {
        //整型常量默认为int
        System.out.println(1024);
        //字符型常量默认为double型
        System.out.println(3.14);
        int a = 100;
        long b = 10;
        b = a;
        //范围大的转范围小的需注意必须明确写出强制类型转换
        a = (int)b;
        System.out.println(a);
        System.out.println(b);
        //特殊情况
        //100 < 127，int类型隐式转换为type类型
        byte c = 100;
        //200 > 127，无法隐式转换，只能强制类型转换，发生截断
        byte d = (byte)200;
        System.out.println(c);
        System.out.println(d);
    }
    public static void main11(String[] args) {
        int a = 10;
        double b = 20;
        //可以通过编译
        b = a;
        /*无法通过编译
        a = b;*/
    }
    public static void main10(String[] args) {
        boolean a = true;
        boolean b = false;
        System.out.println(a);
        System.out.println(b);
    }
    public static void main9(String[] args) {
        char c1 = 'a';
        char c2 = '1';
        //Java中的字符可以存放汉字
        char c3 = '桌';
        System.out.println((int)'A');
        System.out.println((int)c1);
        System.out.println(c2);
        System.out.println(c3);
    }
    public static void main8(String[] args) {
        //float赋值时后面必须加f或者F，否则编译错误
        float a = 2.3f;
        System.out.println(a);
    }
    public static void main7(String[] args) {
        double a = 1.3;
        System.out.println(a);
    }
    public static void main6(String[] args) {
        byte a = 10;
        System.out.println(a);
        System.out.println(Byte.MAX_VALUE);
        System.out.println(Byte.MIN_VALUE);
    }
    public static void main5(String[] args) {
        short a = 3;
        System.out.println(a);
        System.out.println(Short.MAX_VALUE);
        System.out.println(Short.MIN_VALUE);
    }
    public static void main4(String[] args) {
        // long定义的长整型变量1
        long a = 10;
        // long定义的长整型变量2，为了区分类型和规范，建议在后面加上L
        long b = 10L;
        // long型变量所能表示的范围：这个数据范围远超过 int 的表示范围. 足够绝大部分的工程场景使用.
        System.out.println(Long.MIN_VALUE);
        System.out.println(Long.MAX_VALUE);
    }
    public static void main3(String[] args) {
        // 方式一：在定义时给出初始值
        int a = 10;
        System.out.println(a);
        // 方式二：在定义时没有给初始值，但使用前必须设置初值
        int b;
        b = 10;
        System.out.println(b);
    }
    public static void main2(String[] args) {
        //定义在main方法中，局部变量
        //
        int a = 10;
        double d = 5.55;
        char c = 'A';
        boolean b = true;
        // 注意：在一行可以定义多个相同类型的变量
        int a1 = 10, a2 = 20, a3 = 30;
        System.out.println(a1);
        System.out.println(a2);
        System.out.println(a3);
        System.out.println(a);
        System.out.println(Integer.MAX_VALUE);
        System.out.println(Integer.MIN_VALUE);
        System.out.println(d);
        System.out.println(c);
        System.out.println(b);
        a = 100;
        System.out.println(a);
    }
    public static void main1(String[] args) {
        System.out.println("Hello World!");
        System.out.println(100);
        System.out.println(3.14);
        System.out.println('A');
        System.out.println(true);
        System.out.println(false);
    }
}
